package com.ciei.dpagm.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.ciei.dpagm.common.annotation.DefaultValue;
import com.ciei.dpagm.util.DateUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @author fangnuozhou
 * @date 2020/09/01
 */
@TableName(value = "common_right")
public class Right implements java.io.Serializable {
    @TableId(type = IdType.AUTO)
    private Integer rightId;
    private String rightName;
    private Integer rightType;
    @TableField(fill = FieldFill.INSERT)
    @DefaultValue(intValue = 0)
    private Integer parentId;
    private String routerName;
    private String path;
    private String component;
    private String redirect;
    private String rightCode;
    private String icon;
    @TableField(fill = FieldFill.INSERT)
    @DefaultValue(intValue = 1)
    private Integer orderId;
    @TableField(fill = FieldFill.INSERT)
    @DefaultValue(intValue = 0)
    private Integer disable;
    @TableField(fill = FieldFill.INSERT)
    @DefaultValue(intValue = 0)
    private Integer hidden;
    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    private Integer isDelete;
    @TableField(fill = FieldFill.INSERT)
    @DefaultValue(intValue = 0)
    private Integer alwaysShow;
    @TableField(fill = FieldFill.INSERT)
    @DefaultValue(intValue = 0)
    private Integer noCache;
    @TableField(fill = FieldFill.INSERT)
    @DefaultValue(intValue = 0)
    private Integer affix;
    private String image;
    private String description;
    @TableField(fill = FieldFill.INSERT)
    @JSONField(format= DateUtil.FORMAT_LONG)
    private Date createTime;
    @TableField(fill = FieldFill.UPDATE)
    @JSONField(format= DateUtil.FORMAT_LONG)
    private Date updateTime;
    /**
     * 子节点
     */
    @TableField(exist = false)
    private List<Right> children = new ArrayList<>();

    public Right() {
    }

    public Right(Integer rightId, String rightName, Integer rightType, Integer parentId, String routerName, String path
            , String component, String redirect, String rightCode, String icon, Integer orderId, Integer disable
            , Integer hidden, Integer isDelete, Integer alwaysShow, Integer noCache, Integer affix, String image
            , String description, Date createTime, Date updateTime, List<Right> children) {
        this.rightId = rightId;
        this.rightName = rightName;
        this.rightType = rightType;
        this.parentId = parentId;
        this.routerName = routerName;
        this.path = path;
        this.component = component;
        this.redirect = redirect;
        this.rightCode = rightCode;
        this.icon = icon;
        this.orderId = orderId;
        this.disable = disable;
        this.hidden = hidden;
        this.isDelete = isDelete;
        this.alwaysShow = alwaysShow;
        this.noCache = noCache;
        this.affix = affix;
        this.image = image;
        this.description = description;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.children = children;
    }

    public Integer getRightId() {
        return rightId;
    }

    public void setRightId(Integer rightId) {
        this.rightId = rightId;
    }

    public String getRightName() {
        return rightName;
    }

    public void setRightName(String rightName) {
        this.rightName = rightName;
    }

    public Integer getRightType() {
        return rightType;
    }

    public void setRightType(Integer rightType) {
        this.rightType = rightType;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public String getRouterName() {
        return routerName;
    }

    public void setRouterName(String routerName) {
        this.routerName = routerName;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getComponent() {
        return component;
    }

    public void setComponent(String component) {
        this.component = component;
    }

    public String getRedirect() {
        return redirect;
    }

    public void setRedirect(String redirect) {
        this.redirect = redirect;
    }

    public String getRightCode() {
        return rightCode;
    }

    public void setRightCode(String rightCode) {
        this.rightCode = rightCode;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public Integer getDisable() {
        return disable;
    }

    public void setDisable(Integer disable) {
        this.disable = disable;
    }

    public Integer getHidden() {
        return hidden;
    }

    public void setHidden(Integer hidden) {
        this.hidden = hidden;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    public Integer getAlwaysShow() {
        return alwaysShow;
    }

    public void setAlwaysShow(Integer alwaysShow) {
        this.alwaysShow = alwaysShow;
    }

    public Integer getNoCache() {
        return noCache;
    }

    public void setNoCache(Integer noCache) {
        this.noCache = noCache;
    }

    public Integer getAffix() {
        return affix;
    }

    public void setAffix(Integer affix) {
        this.affix = affix;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public List<Right> getChildren() {
        return children;
    }

    public void setChildren(List<Right> children) {
        this.children = children;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Right right = (Right) o;
        return Objects.equals(rightId, right.rightId) &&
                Objects.equals(rightName, right.rightName) &&
                Objects.equals(rightType, right.rightType) &&
                Objects.equals(parentId, right.parentId) &&
                Objects.equals(routerName, right.routerName) &&
                Objects.equals(path, right.path) &&
                Objects.equals(component, right.component) &&
                Objects.equals(redirect, right.redirect) &&
                Objects.equals(rightCode, right.rightCode) &&
                Objects.equals(icon, right.icon) &&
                Objects.equals(orderId, right.orderId) &&
                Objects.equals(disable, right.disable) &&
                Objects.equals(hidden, right.hidden) &&
                Objects.equals(isDelete, right.isDelete) &&
                Objects.equals(alwaysShow, right.alwaysShow) &&
                Objects.equals(noCache, right.noCache) &&
                Objects.equals(affix, right.affix) &&
                Objects.equals(image, right.image) &&
                Objects.equals(description, right.description) &&
                Objects.equals(createTime, right.createTime) &&
                Objects.equals(updateTime, right.updateTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(rightId, rightName, rightType, parentId, routerName, path, component, redirect, rightCode
                , icon, orderId, disable, hidden, isDelete, alwaysShow, noCache, affix, image, description, createTime, updateTime);
    }
}
